<% padding = "2px" %>
<% size_font_general = 11 %>
<% form_tag materials_save_wish_list_path, :method => 'post' do %>
<% image_path_absolute = Setting.image_path_absolute %>
<% image_path_relative = Setting.image_path_relative %>

<%= hidden_field_tag :material_selected, @material.id %>

<div class="portlet" style="width:99%">
  <div class="portlet-header">
     <h1><%=t ".title"%></h1>
  </div>

  <div class="portlet-content">
      <table style="width: 100%;vertical-align: top;border:0;padding: 0;">
        <tr>
          <td style="width: 100px;vertical-align: top;border:0;">
            <% if @material.image != "" && File.exists?("#{image_path_absolute}/#{@material.image}") %>
              <%= image_tag "/#{image_path_relative}/#{@material.image}", :alt => "#{t('no_image')}",  :width=>"150px"  %>
            <% else %>
              <%= image_tag "/#{image_path_relative}/empty_image.jpg", :alt => "#{t('no_image')}",  :width=>"150px"  %>
            <% end %>
          </td>
          <td>
            <table style="width: 100%;vertical-align: top;border:0;padding: 0;">
              <tr>
                <td style="font-size: 15px; padding: <%=padding%>;" colspan="2" >
              <%
                 title = @material.title
                 if !@material.sub_title.nil? && @material.sub_title != ""
                   title += " : #{@material.sub_title}"
                 end
              %>
                  <strong><%=title %></strong>
                </td>
              </tr>
              <tr><td></td></tr>
              <tr>
                <td style=" width: 100px; padding: <%=padding%>;"><strong><%=t('author_filter')%></strong></td>
                <td style="padding: <%=padding%>;">
                  <% first = true %>
                  <%array_sort = @material.authors.sort_by {|a| a.last_name}%>
                  <% array_sort.each do |autor|%>
                    <% if !first %>
                     ;
                    <% end %>
                    <%=link_to "#{autor.last_name}, #{autor.first_name}",
                      :controller => "catalogs", :action => "find_only_param",
                      :id => 0,
                      :author_id => autor.id%>
                    <% first = false %>
                  <% end %>
                </td>
              </tr>

              <tr>
                <td style="padding: <%=padding%>;"><strong><%=t('publisher_filter')%></strong></td>
                <td style="padding: <%=padding%>;">
                  <% first = true %>
                  <% @material.publishers.each do |publisher|%>
                    <%=link_to "#{publisher.city.name} : ", :controller => "catalogs", :action => "find_only_param", :id => 0, :country_id => publisher.city.state.country.id  %>
                    <%=link_to "#{publisher.name}",
                      :controller => "catalogs", :action => "find_only_param",
                      :id => 0, :publisher_id => publisher.id %>
                    <% if !first %>
                      <br/>
                    <% end %>
                    <% first = false %>
                  <% end %>
                  <% if !@material.edition_year.nil? && @material.edition_year != 0 %>
                    <%= ",#{@material.edition_year}."%>
                  <% end %>
                </td>
              </tr>

              <tr>
                <td style="padding: <%=padding%>;"><strong>ISBN:</strong></td>
                <td style="padding: <%=padding%>;"><%=  @material.isbn %></td>
              </tr>

              <tr>
                <td style="padding: <%=padding%>;"><strong><%="#{t('.description')}:"%></strong></td>
                <td style="padding: <%=padding%>;">
                  <% if !@material.pages.nil? && @material.pages != "" %>
                    <%= @material.pages %> p.;
                  <% end %>
                  <% if !@material.height.nil? && @material.height != "" %>
                    <%= @material.height %> cm.
                  <% end %>
                </td>
              </tr>
              <tr style="vertical-align: top">
                <td style="padding: <%=padding%>;"><strong><%="#{t('.comment')}:"%></strong></td>
                <td style="padding: <%=padding%>;"><%= @material.comment %></td>
              </tr>
              <tr>
                <td style="padding: <%=padding%>;" colspan="2">
                  <br/>
                  <% @material.descriptors.each do |descriptor|%>
                    /
                    <%=descriptor.description%>
                  <% end %>
                  <br/>
                </td>
              </tr>
              <tr style="padding: 0">
                <table style="padding: 0; border: 0; width: 300px" cellpadding="0" cellspacing="0">
                  <% if !current_user.nil? %>
                    <td align="left"> <strong> <%="#{@material.currency.symbol} #{"%.2f" % @material.price}" %> </strong></td>
                    <td align="right">
                      <strong>
                        <%= 
                        if  AdministratorSystem::AdministratorSystemProxy::material_stock(@material) > 0
                          t('material_stock_available')
                        else
                            t('material_stock_check_available')
                        end
                        %>
                      </strong>
                    </td>

                  <% end %>
                </table>
              </tr>
              <tr style="padding: 0">
                <td></td>
                <td>
                  <% if !current_user.nil? %>
                    <table style="border:none;" cellspacing="0" cellpadding="0">
                      <tr style="padding: 0">
                        <td align="left"><%=label_tag t('wish_list_selector')%></td>
                        <td align="left"><%=select_tag('wish_list_selected', options_for_select([[t("lbl_select"), -1]] + @wish_lists.map {|u| if u.type_list != WishList::TYPE_SIMPLE then [t(u.name),u.id] else [u.name,u.id] end}), :style => "font-size:#{size_font_general}px;" ) %></td>
                        <td align="left"><%=submit_tag t('lbl_save_wishlist'), :name => nil, :style => "font-size:#{size_font_general}px;" %> </td>
                      </tr>
                    </table>
                  <% end %>
                </td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
      <% if !session[:special_return_to_controller].nil? %>
        <%=link_to t('btn_back'), :controller => session[:special_return_to_controller], :action => :special_return_to%>
      <% end %>
    </div>
</div>
<% end %>